﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:FirstFloor.ModernUI.Windows.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Converters.xaml" />
        <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ListBox.xaml" />
    </ResourceDictionary.MergedDictionaries>
    
    <Style TargetType="controls:ModernMenu">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ModernMenu">
                    <Grid>
                        <Grid.Resources>
                            <Style TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
                                <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/>
                                <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                                <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
                            </Style>
                        </Grid.Resources>
                        
                        <Grid.RowDefinitions>
                            <RowDefinition Height="40" />
                            <RowDefinition Height="16" />
                        </Grid.RowDefinitions>

                        <ListBox ItemsSource="{TemplateBinding VisibleLinkGroups}"
                                 SelectedItem="{Binding SelectedLinkGroup, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
                            <ListBox.ItemContainerStyle>
                                <Style TargetType="ListBoxItem">
                                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                                    <Setter Property="FontFamily" Value="微软雅黑 Light" />
                                    <Setter Property="Foreground" Value="{DynamicResource MenuText}" />
                                    <Setter Property="FontSize" Value="23"/>
                                    <Setter Property="HorizontalContentAlignment" Value="Center" />
                                    <Setter Property="VerticalContentAlignment" Value="Center" />
                                    <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
                                    <Setter Property="Margin" Value="0,0,12,0" />
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ListBoxItem">
                                                <TextBlock DataContext="{TemplateBinding Content}"
                                                           Text="{Binding DisplayName, Converter={StaticResource ToLowerConverter}}"
                                                           HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                           VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                           SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="true">
                                                        <Setter Property="Foreground" Value="{DynamicResource MenuTextHover}"/>
                                                    </Trigger>
                                                    <Trigger Property="IsSelected" Value="true">
                                                        <Setter Property="Foreground" Value="{DynamicResource MenuTextSelected}"/>
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ListBox.ItemContainerStyle>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                        </ListBox>

                        <ListBox Grid.Row="1"
                                 ItemsSource="{Binding SelectedLinkGroup.Links, RelativeSource={RelativeSource TemplatedParent}}"
                                 SelectedItem="{Binding SelectedLink, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                                 VerticalAlignment="Top">
                            <ListBox.ItemContainerStyle>
                                <Style TargetType="ListBoxItem">
                                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                                    <Setter Property="FontFamily" Value="微软雅黑" />
                                    <Setter Property="Foreground" Value="{DynamicResource SubMenuText}" />
                                    <Setter Property="FontSize" Value="11"/>
                                    <Setter Property="Margin" Value="0,0,12,0" />
                                    <Setter Property="HorizontalContentAlignment" Value="Center" />
                                    <Setter Property="VerticalContentAlignment" Value="Center" />
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ListBoxItem">
                                                <Grid DataContext="{TemplateBinding Content}"
                                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                                                    <TextBlock Text="{Binding DisplayName, Converter={StaticResource ToUpperConverter}}" TextAlignment="Center"/>
                                                    <TextBlock Text="{Binding DisplayName, Converter={StaticResource ToUpperConverter}}" FontWeight="Bold" Visibility="Hidden" />
                                                </Grid>
                                                
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="true">
                                                        <Setter Property="Foreground" Value="{DynamicResource SubMenuTextHover}"/>
                                                    </Trigger>
                                                    <Trigger Property="IsSelected" Value="true">
                                                        <Setter Property="Foreground" Value="{DynamicResource SubMenuTextSelected}"/>
                                                        <Setter Property="FontWeight" Value="Bold" />
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ListBox.ItemContainerStyle>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                        </ListBox>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>